<?php

namespace App\Http\Models\Business;

use App\Http\Models\BaseModel;

class InvoiceDetails extends BaseModel
{
    protected $table = 'invoice_details_sd002';

    protected $fillable = [
        'year',
        'month',
        'sales_order_no',
        'sales_order_line_no',
        'material',
        'quantity',
        'total_price_tax_discount',
        'total_price_tax',
        'total_price_no_tax',
        'tax',
        'discount',
        'surcharge',
        'sales_order_type',
        'project_type',
        'sales_organization',
        'sales_region',
        'sales_office',
        'distribution_channel',
        'payer_id',
        'salesman'
    ];

    public function sales_order_type()
    {
        return $this->belongsTo('App\Http\Models\SalesOrderType', 'sales_order_type_code', 'code');
    }

    public function project_type()
    {
        return $this->belongsTo('App\Http\Models\ProjectType', 'project_type_code', 'code');
    }

    public function sales_organization()
    {
        return $this->belongsTo('App\Http\Models\SalesOrganization', 'sales_organization_code', 'code');
    }

    public function sales_region()
    {
        return $this->belongsTo('App\Http\Models\SalesRegion', 'sales_region_code', 'code');
    }

    public function sales_office()
    {
        return $this->belongsTo('App\Http\Models\SalesOffice', 'sales_office_code', 'code');
    }

    public function distribution_channel()
    {
        return $this->belongsTo('App\Http\Models\DistributionChannel', 'distribution_channel_code', 'code');
    }

    public function payer()
    {
        return $this->belongsTo('App\Http\Models\Business\Payer', 'payer_id', 'payer_id');
    }

    public function salesman()
    {
        return $this->belongsTo('App\Http\Models\Salesman', 'salesman_id', 'job_number');
    }
}
